import dd from 'gdt-jsapi'
import * as services from '../../services'
Page({
  data: {
    activeTab: 0,
    tableHeader: [],
    tabs: [
      { title: '专项组督查整改率', tableHeader: ['专项组督查', '整改率'] },
      { title: '创建办督察整改率', tableHeader: ['创建办督察', '整改率'] },
      { title: '点位长自查率', tableHeader: ['点位长', '自查率'] },
      { title: '完成的整改点各专线组平均时效排名', tableHeader: ['专项组', '平均时长'] },
      { title: '完成的整改点各点位长平均时效排名', tableHeader: ['点位长', '平均时长'] },
      { title: '未完成的整改点各专线组累计扣分排名', tableHeader: ['专项组', '累计扣分'] },
      { title: '未完成的整改点各点位长累计扣分排名', tableHeader: ['点位长', '累计扣分'] }
    ],
    reportList: [

    ],
    /**
     * 8. 查询专项组督查整改率
     * checkName rate
     */
    specialWorkingGroupRectificationRateReport: [],
    /**
     * 9. 查询创建办督查整改率
     * checkName rate
     */
    createOfficeRectificationRateReport: [],
    /**
     * 10. 查询点位长自查率
     * checkName rate
     */
    poLocOwnerSelfCheckRateReport: [],
    /**
     * 11. 查询完成的整改点各专线组平均时效排名
     * agingName averageDuration
     */
    specialWorkingGroupAgingReport: [],
    /**
     * 12. 查询完成的整改点各点位长平均时效排名
     * agingName averageDuration
     */
    poLocOwnerAgingReport: [],
    /**
     * 13. 查询未完成的整改点各专线组累计扣分排名
     * deductMarksName deductMarksValue
     */
    specialWorkingGroupDeductMarksReport: [],
    /**
     * 14. 查询未完成的整改点各点位长累计扣分排名
     * deductMarksName deductMarksValue
     */
    poLocOwnerdeDuctMarksReport: [],
  },
  onLoad() {
    this.getReport()
  },
  async getReport() {
    dd.showLoading({ text: "加载中" })
    const {
      specialWorkingGroupRectificationRateReport,
      createOfficeRectificationRateReport,
      poLocOwnerSelfCheckRateReport,
      specialWorkingGroupAgingReport,
      poLocOwnerAgingReport,
      specialWorkingGroupDeductMarksReport,
      poLocOwnerdeDuctMarksReport
    } = await services.getReport();
    dd.hideLoading()
    this.setData({
      specialWorkingGroupRectificationRateReport,
      createOfficeRectificationRateReport,
      poLocOwnerSelfCheckRateReport,
      specialWorkingGroupAgingReport,
      poLocOwnerAgingReport,
      specialWorkingGroupDeductMarksReport,
      poLocOwnerdeDuctMarksReport,
      reportList: [
        specialWorkingGroupRectificationRateReport,
        createOfficeRectificationRateReport,
        poLocOwnerSelfCheckRateReport,
        specialWorkingGroupAgingReport,
        poLocOwnerAgingReport,
        specialWorkingGroupDeductMarksReport,
        poLocOwnerdeDuctMarksReport
      ]
    })
  },
  handleTabClick({ index, tabsName }) {
    this.setData({ [tabsName]: index });
  },
  handleTabChange({ index, tabsName }) {
    this.setData({ [tabsName]: index });
  },
});
